function [A,angle] = Function_ULA_code_DFT2(M,theta_b)
t = -1 : 2 / M : (M-1) / M;
% rows
g = 0 :(M-1);
A = exp(-1j * pi * g' * t);

angle = acos(t) /pi * 180;

ini_b = 180;
for ii = 1:M
   delta_b = abs(theta_b - angle(ii));
   if delta_b < ini_b
        ini_b = delta_b;
        DFTindice = ii;
   end
end

delta_theta = angle(DFTindice) - theta_b;
for ii_d = 1 : M
    angle(ii_d) = angle(ii_d) - delta_theta;
    if angle(ii_d) > 180
        angle(ii_d) = angle(ii_d) - 180;
    end
    if angle(ii_d) < 0
        angle(ii_d) = angle(ii_d) + 180;
    end
end

for ii_m = 1 : M
    A(:,ii_m) = exp(-1j * pi * g * cos(angle(ii_m) / 180 * pi));
end

